package dao

import (
	"gorm.io/gorm"
	"time"
)

// @Description
// @Author 代码小学生王木木

type UserMode struct {
	gorm.Model
	Username    string    `gorm:"uniqueIndex;not null;type:varchar(32);column:username;comment:用户名，唯一索引，不能为空"`
	Phone       string    `gorm:"index;type:varchar(32);comment:手机号;column:phone"`
	Email       string    `gorm:"index;type:varchar(128);comment:邮箱;column:email"`
	Description string    `gorm:"type:text;comment:个性签名(描述);column:description"`
	Password    string    `gorm:"type:varchar(128);comment:密码;column:password"`
	Nickname    string    `gorm:"type:varchar(128);comment:昵称;column:nickname"`
	Gender      string    `gorm:"type:varchar(128);comment:性别;column:gender"`
	Birthday    time.Time `gorm:"comment:生日;column:birthday;default:null"`
	IsAdmin     int64     `gorm:"int;default:0;comment:是否是admin，默认0,非管理员;column:gender"`
	Avatar      string    `gorm:"type:varchar(200);comment:用户头像"`
	CreateId    int64     `gorm:"comment:创建人ID;not null;"`
}

func (UserMode) TableName() string {
	return "eb_users"
}

type ArticleModel struct {
	gorm.Model
	AuthorId int64  `gorm:"index:idx_article_user_id;comment:作者ID" `                                  // 所属用户编号
	Title    string `gorm:"size:128;not null;comment:标题" `                                            // 标题
	Content  string `gorm:"type:longtext;not null;comment:内容" `                                       // 内容
	Status   int    `gorm:"type:int(11);index:idx_article_status;comment:状态 0 草稿，1 待审核，2 审核通过，3 发布" ` // 状态
}

func (ArticleModel) TableName() string {
	return "eb_articles_edit"
}

type PublishArticleModels struct {
	ArticleModel
}

func (PublishArticleModels) TableName() string {
	return "eb_articles_pub"
}

type InteractiveModel struct {
	gorm.Model
	// 同一个资源只能有一行，也就是要有联合唯一索引
	BizId      int64  `gorm:"comment:业务ID;not null;uniqueIndex:id_type_biz"` // 因为建立联合索引时候，索引的顺序只和结构体字段的顺序有关，所以要注意 bizID和biz的顺序不能乱
	Biz        string `gorm:"comment:业务标识符;type:varchar(128);not null;uniqueIndex:id_type_biz"`
	ReadCnt    int64  `gorm:"comment:阅读数;default:0"` // 阅读计数
	LikeCnt    int64  `gorm:"comment:点赞数;default:0"` // 点赞数
	CollectCnt int64  `gorm:"comment:收藏数;default:0"` // 收藏数
	CommentCnt int64  `gorm:"comment:评论数;default:0"` // 评论数
}

func (InteractiveModel) TableName() string {
	return "eb_interactive"
}

// UserLikeBizModel 用户点赞资源关联表
type UserLikeBizModel struct {
	gorm.Model
	// 思考一下为什么联合索引的顺序是 bizid biz uid （提示: 根据业务场景来）
	BizId int64  `gorm:"comment:业务ID;not null;uniqueIndex:uid_type_biz"` // 因为建立联合索引时候，索引的顺序只和结构体字段的顺序有关，所以要注意 bizID和biz的顺序不能乱
	Biz   string `gorm:"comment:业务标识符;type:varchar(128);not null;uniqueIndex:uid_type_biz"`
	Uid   int64  `gorm:"comment:用户ID;not null;uniqueIndex:uid_type_biz"`
}

func (UserLikeBizModel) TableName() string {
	return "eb_user_to_biz_like"
}

// CollectionModle
// @Description: 收藏夹
type CollectionModle struct {
	gorm.Model
	// 用户id和收藏夹的联合索引
	UserId      int64  `gorm:"用户ID;not null;column:user_id;uniqueIndex:uni_uid_cname"`
	CName       string `gorm:"comment:收藏夹名称;type:varchar(32);not null;column:c_name;uniqueIndex:uni_uid_cname"`
	Description string `gorm:"comment:收藏夹描述(可选);type:varchar(1024);column:description"`
	Sort        int64  `gorm:"comment:收藏夹排序;default:0;type:int;column:sort"`
	ResourceNum int64  `gorm:"comment:收藏夹内资源的数量;not null;default:0;column:resource_num"`
	IsPub       bool   `gorm:"comment:是否公开;column:is_pub"`
	CommentNum  int64  `gorm:"comment:收藏夹评论数量;not null;default:0;column:comment_num"`
}

func (CollectionModle) TableName() string {
	return "eb_collect"
}

// UserCollectBizModel
// @Description: 业务收藏夹关联表
type UserCollectBizModel struct {
	gorm.Model
	BizId int64  `gorm:"comment:业务ID;not null;uniqueIndex:uid_type_biz"` // 因为建立联合索引时候，索引的顺序只和结构体字段的顺序有关，所以要注意 bizID和biz的顺序不能乱
	Biz   string `gorm:"comment:业务标识符;type:varchar(128);not null;uniqueIndex:uid_type_biz"`
	Uid   int64  `gorm:"comment:用户ID;not null;uniqueIndex:uid_type_biz"`
	Cid   int64  `gorm:"comment:收藏夹的ID;index"`
}

func (UserCollectBizModel) TableName() string {
	return "eb_user_to_biz_collect"
}

type CompanyTactModel struct {
	gorm.Model
	TaxCode     string `gorm:"type:varchar(32);default:;comment:一社会信用码/注册码;column:tac_code;"`
	Duty        string `gorm:"type:varchar(32);default:;comment:联系人职位;column:duty"`
	Idx         string `gorm:"type:varchar(32);default:;comment:联系方式权重;column:idx"`
	Contact     string `gorm:"type:varchar(32);default:;comment:联系方式;column:contact"`
	ContactTool string `gorm:"type:varchar(32);default:;comment:联系方式类型（手机/座机/邮箱）;column:contact_tool"`
	Lid         string `gorm:"type:varchar(32);default:;comment:联系方式唯一标识;column:lid"`
	Name        string `gorm:"type:varchar(32);default:;comment:联系人姓名;column:name"`
	Quhao       string `gorm:"type:varchar(32);default:;comment:手机归属地/座机区号;column:quhao"`
	Source      string `gorm:"type:varchar(32);default:;comment:联系方式来源（年报、招聘、B2B 黄页...）;column:source"`
	URL         string `gorm:"type:varchar(32);default:;comment:联系方式来源网页链接;column:url"`
}

func (CompanyTactModel) TableName() string {
	return "eb_company_contact"
}

type TaxPayerInfoModel struct {
	gorm.Model
	BuyerTaxIde              string `gorm:"column:buyer_tax_ide;comment:'购方税号'"`
	BuyerName                string `gorm:"column:buyer_name;comment:'购方名称'"`
	BuyerBankNameAcc         string `gorm:"column:buyer_bank_name_acc;comment:'购买方开户行及账号'"`
	Sign                     string `gorm:"column:sign;comment:'进销项标识：进项、销项'"`
	InvType                  string `gorm:"column:inv_type;comment:'发票种类代码：01--增值税专用发票,02--货物运输业增值税专用发票,03--机动车销售统一发票,04--增值税普通发票,08--电子专用发票,10--电子普通发票,11--卷式普通发票,14--电子普通[通行费]发票,15--二手车统一发票,99--通用机打发票'"`
	Money                    string `gorm:"column:money;comment:'金额(不含税);二手车发票对应“车价合计”'"`
	Tonnage                  string `gorm:"column:tonnage;comment:'吨位'"`
	RestrictPopulation       string `gorm:"column:restrict_population;comment:'限乘人数'"`
	CreateDate               string `gorm:"column:create_date;comment:'开票日期'"`
	Remark                   string `gorm:"column:remark;type:text;comment:'备注'"`
	SellerAddTel             string `gorm:"column:seller_add_tel;comment:'销方地址电话'"`
	BelongMonth              string `gorm:"column:belong_month;comment:'所属月份'"`
	VehicleType              string `gorm:"column:vehicle_type;comment:'车辆类型'"`
	QualifiedNo              string `gorm:"column:qualified_no;comment:'合格证号'"`
	ProductionAddress        string `gorm:"column:production_address;comment:'产地'"`
	InvNo                    string `gorm:"column:inv_no;comment:'发票代码'"`
	TaxMoney                 string `gorm:"column:tax_money;comment:'合计税额'"`
	VehicleCode              string `gorm:"column:vehicle_code;comment:'车辆识别代号/车架号码'"`
	Drawer                   string `gorm:"column:drawer;comment:'开票人'"`
	Source                   string `gorm:"column:source;comment:'发票来源 0: pc,1:h5 以及其他'"`
	CommodityInspectionNo    string `gorm:"column:commodity_inspection_no;comment:'商检单号'"`
	SellerBankNameAcc        string `gorm:"column:seller_bank_name_acc;comment:'销售方开户行及账号'"`
	FactoryPlateModel        string `gorm:"column:factory_plate_model;comment:'厂牌型号'"`
	BuyerAddTel              string `gorm:"column:buyer_add_tel;comment:'购方地址电话'"`
	ImportationCertificateNo string `gorm:"column:importation_certificate_no;comment:'进口证明书号'"`
	Amount                   string `gorm:"column:amount;comment:'价税合计'"`
	SellerTaxIde             string `gorm:"column:seller_tax_ide;comment:'销方税号'"`
	SellerName               string `gorm:"column:seller_name;comment:'销方名称'"`
	InvalidSign              string `gorm:"column:invalid_sign;comment:'作废标志'"`
	InvStatus                string `gorm:"column:inv_status;comment:'发票状态'"`
	InvNum                   string `gorm:"column:inv_num;comment:'发票号码'"`
	CheckCode                string `gorm:"column:check_code;comment:'校验码'"`
	TaxpayerID               string `gorm:"column:taxpayer_id;not null;comment:'纳税识别号'"`
	CreateTime               int    `gorm:"column:create_time;comment:'创建时间'"`
}

func (TaxPayerInfoModel) TableName() string {
	return "eb_taxpayer_info_invoice"
}

type EnterpriseBasicModel struct {
	gorm.Model
	CompanyName                string    `gorm:"column:company_name;index;comment:企业名称;not null;type:varchar(200);"`
	RegStatus                  string    `gorm:"column:reg_status;comment:登记状态;type:varchar(32);"`
	LegalBoss                  string    `gorm:"column:legal_boss;comment:法定代表人;type:varchar(64);"`
	RegCapital                 string    `gorm:"column:reg_capital;comment:注册资本;type:varchar(64);"`
	RegDate                    time.Time `gorm:"column:reg_date;default:null;comment:成立日期;"`
	SocialCode                 string    `gorm:"column:social_code;uniqueIndex;comment:统一社会信用代码;not null;type:varchar(32);"`
	CompanyRegAddr             string    `gorm:"column:company_reg_addr;comment:企业注册地址;type:varchar(255);"`
	Phone                      string    `gorm:"column:phone;comment:电话;type:varchar(32);"`
	Email                      string    `gorm:"column:email;comment:邮箱;type:varchar(100);"`
	Province                   string    `gorm:"column:province;comment:所属省份;type:varchar(64);"`
	City                       string    `gorm:"column:city;comment:所属城市;type:varchar(100);"`
	District                   string    `gorm:"column:district;comment:所属区县;type:varchar(100);"`
	TaxNumber                  string    `gorm:"column:tax_number;comment:纳税人识别号;type:varchar(32);"`
	RegNumber                  string    `gorm:"column:reg_number;comment:注册号;type:varchar(32);"`
	OrgCode                    string    `gorm:"column:org_code;comment:组织机构代码;type:varchar(32);"`
	InsuredNumber              int       `gorm:"column:insured_number;comment:参保人数;type:varchar(32);"`
	InsuredNumberReport        string    `gorm:"column:insured_number_report;comment:参保人数所属年报;type:varchar(32);"`
	CompanyType                string    `gorm:"column:company_type;comment:企业(机构)类型;type:varchar(32);"`
	CompanySize                string    `gorm:"column:company_size;comment:企业规模;type:varchar(32);"`
	ApprovalDate               time.Time `gorm:"column:approval_date;comment:核准日期;default:null;type:varchar(32);"`
	BusinessTerm               string    `gorm:"column:business_term;comment:营业期限;type:varchar(64);"`
	GBIndustryCategory         string    `gorm:"column:gb_industry_category;comment:国标行业门类;type:varchar(100);"`
	GBIndustryMajorCategory    string    `gorm:"column:gb_industry_major_category;comment:国标行业大类;type:varchar(100);"`
	GBIndustryMediumCategory   string    `gorm:"column:gb_industry_medium_category;comment:国标行业中类;type:varchar(100);"`
	GBIndustrySmallCategory    string    `gorm:"column:gb_industry_small_category;comment:国标行业小类;type:varchar(100);"`
	FormerName                 string    `gorm:"column:former_name;comment:曾用名;type:varchar(255);"`
	EnglishName                string    `gorm:"column:english_name;comment:英文名;type:varchar(200);"`
	OfficialWebsite            string    `gorm:"column:official_website;comment:官网网址;type:varchar(255);"`
	CommunicationAdd           string    `gorm:"column:communication_add;comment:通信地址;type:varchar(500);"`
	CompanyProfile             string    `gorm:"column:company_profile;comment:企业简介;type:varchar(500);"`
	BusinessScope              string    `gorm:"column:business_scope;comment:经营范围;type:varchar(500);"`
	EBIPIndustryCategory       string    `gorm:"column:qcc_industry_category;comment:EBIP行业门类;type:varchar(100);"`
	EBIPIndustryMajorCategory  string    `gorm:"column:qcc_industry_major_category;comment:EBIP行业大类;type:varchar(100);"`
	EBIPIndustryMediumCategory string    `gorm:"column:qcc_industry_medium_category;comment:EBIP行业中类;type:varchar(100);"`
	EBIPIndustrySmallCategory  string    `gorm:"column:qcc_industry_small_category;comment:EBIP行业小类;type:varchar(100);"`
}

func (EnterpriseBasicModel) TableName() string {
	return "eb_enterprise_basic_info"
}
